/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-07-11 08:26:06
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Api.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton, OpenSelection } from '../Common/options'

export const RiskLevelListPeriod = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}ORG`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
            <OpenSelection
                OptionsEvent={OptionsEvent}
                title="批量删除"
                type="primary"
                danger
                data={{
                    type: 'SelectionDelete',
                    url: 'posRiskLevelListPeriodBatchRemove',
                }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, width: 400 },
            { ...commonTableList.tableName, title: '名称' },
            {
                dataIndex: 'yearMonth',
                title: '巡检日期',
                valueType: 'Date',
                picker: 'month',
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            { ...commonTableList.remark, hideInSearch: true },
            commonTableList.BeginDate,
            commonTableList.EndDate,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 360,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        <OpenExcelButton
                            key="open1"
                            title="编辑表单"
                            OptionsEvent={OptionsEvent}
                            data={{
                                submit: true,
                                save: true,
                                url: 'getRiskLevelListTemplate',
                                pos: 'posRiskLevelListBatch',
                                path: [uuid],
                            }}
                        />,
                        <OpenExcelButton
                            key="open2"
                            title="查看excel"
                            OptionsEvent={OptionsEvent}
                            data={{
                                save: true,
                                url: 'getRiskLevelListExport',
                                path: [uuid],
                            }}
                        />,
                        <OpenExcelButton
                            key="open3"
                            title="与上月对比"
                            OptionsEvent={OptionsEvent}
                            data={{
                                save: true,
                                url: 'getRiskGetRiskStatList',
                                path: [uuid],
                            }}
                        />,
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
